﻿<%@ Page Title="" Language="C#" MasterPageFile="~/pages/Site.Master" AutoEventWireup="true" CodeBehind="HogPurchase.aspx.cs" Inherits="OnlineManagement.Web.pages.HogPurchase" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
  <link href="../resources/css/jquery.ui.all.css" rel="stylesheet" type="text/css" />
    <script src="../resources/scripts/jquery.ui.core.js" type="text/javascript"></script>
    <script src="../resources/scripts/jquery.ui.datepicker.js" type="text/javascript"></script>
    <script src="../resources/scripts/jquery.ui.widget.js" type="text/javascript"></script>
    <script src="../resources/scripts/jquery.ui.datepicker-zh-TW.js" type="text/javascript"></script>
    <script src="../resources/scripts/myAjax.js" type="text/javascript"></script>
      <script src="../resources/scripts/facebox.js" type="text/javascript"></script>
    <script src="../resources/scripts/jquery.cookie.js" type="text/javascript"></script>

    <script src="../resources/scripts/jquery.ui.position.js" type="text/javascript"></script>
    <script src="../resources/scripts/jquery.ui.tooltip.js" type="text/javascript"></script>
    <script src="../resources/scripts/jquery.ui.effect.js" type="text/javascript"></script>
    <script src="../resources/scripts/jquery.ui.effect-explode.js" type="text/javascript"></script>
    <script src="../resources/scripts/jsHogPurchase.js" type="text/javascript"></script>
    <script type="text/javascript" language="javascript">
        $(document).ready(function () {
           
            //默认为元/斤
            var hogUnitName = 1;
            $("#btnSave").click(function () {
                //var bitID = $("#txtBitID").val();
                //var hoggerId = $.cookie("hoggeryId");
                var hoggerId = 1001;
                var hogCategory = $("#spCategory").text();
                var hogType = $("#<%=ddlHogType.ClientID %>").val();
                var isPurchaseWhole = $("#<%=hfIsPurchaseWhole.ClientID %>").val();
                var pigPenId = $("#<%=ddlPigPen.ClientID %>").val();
                var growPhase = $("#<%=ddlGrowPhase.ClientID %>").val();
                var birthday = $("#txtBirthday").val();
                var purchaseDate = $("#txtPurchaseDate").val();
                var account = $("#txtAccount").val();
                var unitPrice = $("#txtUnitPrice").val();
                var totalWight = $("#txtTotalWight").val();

                $.ajax2({
                    type: "post",
                    contentType: "application/json",
                    url: "../WebServices/HogService.asmx/HogPurchase",
                    dataType: "json",
                    data: "{ hoggeryId: '" + hoggerId + "',pigCategory:'" + hogCategory + "',typeIDStr:'" + hogType + "',isCombine:'" + isPurchaseWhole
                    + "',pigPenIdStr:'" + pigPenId + "',phaseId:'" + growPhase + "',birthdayStr:'" + birthday + "',purchaseDateStr:'" + purchaseDate
                    + "',account:'" + account + "',unitName:'" + hogUnitName + "',unitPriceStr:'" + unitPrice
                     + "',totalWightStr:'" + totalWight + "' }",
                    success: function (data) {
                        if (data.d.Flag) {
                            $("#msg > div").remove();
                            var span = "<div class='notification success png_bg'> <a href='#' class='close'><img src='../resources/images/icons/cross_grey_small.png' title='关闭' alt='关闭' /></a><div>" + data.d.Message + "</div></div>";
                            $("#msg").append(span);
                            __doPostBack('aLink', '');

                        } else {
                            $("#msg > div").remove();
                            var span = "<div class='notification attention png_bg'> <a href='#' class='close'><img src='../resources/images/icons/cross_grey_small.png' title='关闭' alt='关闭' /></a><div>" + data.d.Message + "</div></div>";
                            $("#msg").append(span);
                        }
                    },
                    error: function (error) {
                        $("#msg > div").remove();
                        var span = "<div class='notification error png_bg'> <a href='#' class='close'><img src='../resources/images/icons/cross_grey_small.png' title='关闭' alt='关闭' /></a><div>提交失败：" + error.status + "</div></div>";
                        $("#msg").append(span);
                    }

                });

            });
           

            
          

        });
    </script>

</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
    <div class="content-box-header">
        <h3>
            猪只采购管理</h3>
        <ul class="content-box-tabs">
            <li>
            <a id="t1" href="#tab1" class="default-tab">肉猪采购</a>
            </li>
            <!-- href must be unique and match the id of target div -->
            <li><a id="t2" href="#tab2">仔猪采购</a></li>
        </ul>
        <div class="clear">
        </div>
    </div>
    <div class="content-box-content" >

      <div class="tab-content default-tab" id="tab1">
       <asp:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode="Conditional" ChildrenAsTriggers="true">
        <ContentTemplate>
      <div class="notification attention png_bg"> <a href="#" class="close"><img src="../resources/images/icons/cross_grey_small.png" title="Close this notification" alt="close" /></a>
            <div> 红色星号 <span style=" color:Red">*</span>为必填项目 </div>
          </div>

        <fieldset>
            <!-- Set class to "column-left" or "column-right" on fieldsets to divide the form into columns -->
           <%-- <p>
                <span>耳&nbsp;&nbsp;&nbsp;&nbsp;号：</span>
                <input type="text" id="txtBitID" class="text-input small-input" />
                <span id="spanBitMsg"></span>
            </p>--%>
            <p>
                <span>
                    猪只类型：</span>
                    <span id="spCategory">肉猪</span>
            </p>
            <p>
                <span>猪只品种：</span>
                <asp:DropDownList runat="server" ID="ddlHogType"></asp:DropDownList>
            </p>
            <asp:UpdatePanel ID="UpdatePanel2" runat="server" ChildrenAsTriggers="true" UpdateMode="Conditional">
            <ContentTemplate>
           
           <p>
            <span>整窝购买：</span>
            <asp:CheckBox runat="server" ID="cbFull" AutoPostBack="true"  />是
            <asp:CheckBox runat="server" ID="cbScattered" AutoPostBack="true" Checked="true" />否
          &nbsp;&nbsp;<a href="javascript:void(0);" title="选中'是'-表示将购买的猪添加进新猪圈中；当选中'否'-表示将购买的猪与现有肉猪圈在一起。" id="linkRule">操作说明</a>
           </p>
           
            <p>
                <span>猪圈编号：</span>
                <asp:DropDownList runat="server" ID="ddlPigPen" AutoPostBack="false"></asp:DropDownList><span style=" color:Red;">*</span>
                <a href="javascript:void(0)">查看所有猪圈</a>
                <a href="AddPigPen.aspx" rel="modal" id="linkPigPen">添加猪圈</a>
            </p>
                <asp:HiddenField runat="server" ID="hfIsPurchaseWhole" Value="false" />
              <%--  <a runat="server" id="linkPost" visible="false"></a>--%>
             </ContentTemplate>
             <Triggers>
                <asp:AsyncPostBackTrigger ControlID="cbFull" EventName="CheckedChanged" />
                <asp:AsyncPostBackTrigger  ControlID="cbScattered" EventName="CheckedChanged"/>
            <%--    <asp:AsyncPostBackTrigger ControlID="linkPost" EventName="ServerClick" />--%>
             </Triggers>
            </asp:UpdatePanel>
            <p>
            <span>生长阶段：</span>
                <asp:DropDownList runat="server" ID="ddlGrowPhase" AutoPostBack="false"></asp:DropDownList>
            </p>
            <p>
                <span>出生日期：</span>
                <input type="text" id="txtBirthday" class="text-input small-input" name="small-input" />
            </p>
             <p>
                <span>购买日期：</span>
                <input class="text-input small-input" type="text" id="txtPurchaseDate" name="small-input" />
            </p>
           <p>
            <span>购买数量：</span>
               <input class="text-input small-input" value="1"  type="text" id="txtAccount" name="small-input" onkeyup="JavaScript:this.value=this.value.replace(/\D/gi,'')" />
           </p>
           <p>
            <span>单价单位：</span>
               <input type="checkbox" id="cbUnitName1" checked="checked" />元/斤
               <input type="checkbox" id="cbUnitName2" />元/只
           </p>
           <p>
            <span>购买单价：</span>
               <input class="text-input small-input" type="text" id="txtUnitPrice" name="small-input" />
               <span id="spanUnitName">元/斤</span>
           </p>
           <p>
            <span>总&nbsp;&nbsp;重&nbsp;&nbsp;量：</span>
              <input class="text-input small-input" type="text" id="txtTotalWight" name="small-input" />
           </p>
          
             <p>
              <input class="confirm-button" id="btnSave" type="button" value="保存"/>
              <input class="confirm-button" id="btnCancel" type="button" value="取消" onclick="cancelAction()" />
             </p>
             <p></p>
             <p></p>
             <p>
                <div id="msg"></div>
             </p>
         
        </fieldset>
          </ContentTemplate>
      <Triggers>
       
      <%--  <asp:AsyncPostBackTrigger ControlID="t1" EventName="ServerClick" />--%>
      </Triggers>
        </asp:UpdatePanel>
    </div>

     
    <div class="tab-content" id="tab2">
    <div class="notification attention png_bg"> <a href="#" class="close"><img src="../resources/images/icons/cross_grey_small.png" title="Close this notification" alt="close" /></a>
            <div>日龄38天以内的的猪称为仔猪，购买的仔猪需要与母猪圈在一起。</div>
          </div>
         <fieldset>
            <!-- Set class to "column-left" or "column-right" on fieldsets to divide the form into columns -->
            <p>
                <span>母猪耳号：</span>
                <asp:DropDownList runat="server" ID="ddlSowID"></asp:DropDownList>
            </p>
             <p>
                <span>猪圈编号：</span>
                <asp:Label runat="server" ID="lbPigPen"></asp:Label>
            </p>
           
            <p>
                <span>猪只品种：</span>
                <asp:DropDownList runat="server" ID="ddlPigletType"></asp:DropDownList>
            </p>
           <p>
                <span>
                    猪只类型：</span>
                <asp:DropDownList runat="server" ID="DropDownList1"></asp:DropDownList>
            </p>
           
            <p>
            <span>生长阶段:</span>&nbsp;&nbsp;
                <asp:DropDownList runat="server" ID="DropDownList4"></asp:DropDownList>
            </p>
             <p>
                <span>购买日期：</span>
                <input class="text-input small-input" type="text" id="Text2" name="small-input" />
            </p>
           <p>
            <span>购买数量：</span>
               <input class="text-input small-input" type="text" id="Text3" name="small-input" />
           </p>
           <p>
            <span>总&nbsp;&nbsp;重&nbsp;&nbsp;量：</span>
              <input class="text-input small-input" type="text" id="Text4" name="small-input" />
           </p>
           <p>
            <span>整窝购买：</span>
            <input type="checkbox" id="Checkbox1" value="true" />是
            <input  type="checkbox" id="Checkbox2" checked="checked" value="false" />否
           </p>
             <p>
              <input class="confirm-button" id="Button1" type="button" value="保存"/>
              <input class="confirm-button" id="Button2" type="button" value="取消" onclick="cancelAction()" />
             </p>
             <p></p>
             <p></p>
             <p>
                <div id="Div1"></div>
             </p>
        </fieldset>
    </div>
    </div>

</asp:Content>
